package com.events
{
	import com.greensock.TweenMax;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	
	public class MenuItem extends Sprite
	{
		private var _value:String;  
		private var txt:TextField=new TextField();  
		private var txtFormat:TextFormat=new TextFormat();  
		
		public function MenuItem(caption:String,value:String,
								 _width:int=200,_height:int=20):void
		{
			this.buttonMode=true;  
			this.alpha=.8;  
			_value=value;  
			_width=-10  
			
			this.graphics.beginFill(0x000000);  
			this.graphics.drawRect(0,0,_width,_height);
			
			txtFormat.color=0xFFFFFF;  
			txtFormat.size=10;  
			txtFormat.font="Verdana";  
			
			txt.defaultTextFormat=txtFormat;              
			txt.mouseEnabled=false;  
			txt.text=caption;  
			txt.x=5;  
			txt.y=2;  
			txt.width=_width-10;  
			txt.height=_height-4;  
			addChild(txt);  
			
			addEventListener(Event.ADDED_TO_STAGE,addedToStage);  
			addEventListener(MouseEvent.MOUSE_OVER,mouseOver);  
			addEventListener(MouseEvent.MOUSE_OUT,mouseOut);  
		} 
		
		private function mouseOver(e:MouseEvent):void
		{   
			new TweenMax(this,1,{alpha:1});   
		}
		
		private function mouseOut(e:MouseEvent):void
		{   
			new TweenMax(this,1,{alpha:.8});   
		}
		
		private function addedToStage(e:Event):void
		{   
			this.y=this.parent.getChildIndex(this)*this.height;   
		} 
	}
}